<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title></title>
    <script type="text/javascript" src="https://api.map.baidu.com/api?v=2.0&ak=6VGhUV90mWa04N7QbqrcmkemYNu7fGT8"></script>
</head>
<body>
<div style="width:100%;margin:auto;">
    要查询的地址：<input id="text_" type="text" value="" style="margin-right:10px;width: 400px" readonly/>
    <!--<input type="button" value="查询" onclick="searchByStationName();"/>-->
<div id="container" style="position: absolute;margin-top:30px; width:  98%; height: 90%; top: 20px; border: 1px solid gray;overflow:hidden;"></div>
</div>
</body>
<script type="text/javascript">
    var xaddress =decodeURI(window.location.search.substr(3));
    document.getElementById("text_").value=xaddress;
    var map = new BMap.Map("container");
    map.enableScrollWheelZoom();    //启用滚轮放大缩小，默认禁用
    map.enableContinuousZoom();    //启用地图惯性拖拽，默认禁用
    map.addControl(new BMap.NavigationControl());  //添加默认缩放平移控件
    map.addControl(new BMap.OverviewMapControl()); //添加默认缩略地图控件
    map.addControl(new BMap.OverviewMapControl({ isOpen: true, anchor: BMAP_ANCHOR_BOTTOM_RIGHT }));   //右下角，打开
    var localSearch = new BMap.LocalSearch(map);
    localSearch.enableAutoViewport(); //允许自动调节窗体大小
    var keyword = document.getElementById("text_").value;
    localSearch.setSearchCompleteCallback(function (searchResult) {
        map.clearOverlays();//清空原来的标注
         poi = searchResult.getPoi(0);
        map.centerAndZoom(poi.point, 18);
        var marker = new BMap.Marker(new BMap.Point(poi.point.lng, poi.point.lat));  // 创建标注，为要查询的地址对应的经纬度
        marker.enableDragging();//可拖拽
        marker.addEventListener("dragend",function (e) {//托拽监听事件
                var p = marker.getPosition();
                poi.point.lng=p.lng;
                poi.point.lat=p.lat;
        });
        map.addOverlay(marker);
    });
    localSearch.search(keyword);
</script>
</html>